/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package hashmap;

import java.util.HashMap;
import java.util.Iterator;

/**
 *
 * @author s0920761
 */
public class Hashmap {

    public void hashmap_test(){

   //在HashMap中的对象是无序的
   HashMap hm=new HashMap();
   hm.put("a","wpskl 1");
   hm.put("b","wpskl 3");
   hm.put("c","wpskl 5");
   //测试是否包含关键字"a"
   System.out.println(hm.containsKey("a"));
   System.out.println(hm.containsKey("d"));
   System.out.println(hm.get("a"));
   System.out.println(hm.entrySet());
   Iterator it=hm.entrySet().iterator();
 while(it.hasNext())
   {
    System.out.println(it.next());
   }
   //Set keySet()返回关键字的集合
   it=hm.keySet().iterator();

   while(it.hasNext())
   {

    System.out.println(it.next());

   }
   //Collection values()返回值的集合
   it=hm.values().iterator();
   while(it.hasNext())
   {
    System.out.println(it.next());
   }



    }
}
